﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;
namespace DAL
{
    public class DONVITINHDAO:DALBase
    {
        public DONVITINHDAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPDONVITINH"; }
            set { _SpName = value; }
        }
        public DataTable GetListDONVITINH()
        {
            dt = new DataTable();
            try
            {

                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new DONVITINH(), null), ConvertClassToArray.GetValues(new DONVITINH(), 0));
                return dt;
            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list DONVITINH"); }
        }
		public List<DONVITINH> GetListDONVITINHs()
		{
			dt = new DataTable();
			List<DONVITINH> dsvt = new List<DONVITINH>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new DONVITINH(), null), ConvertClassToArray.GetValues(new DONVITINH(), 0));
				dsvt = (List<DONVITINH>)ConvertDatatableToList.ConvertTo<DONVITINH>(dt);

			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list DONVITINH"); }
			return dsvt;
		}
        public String CreatenewId()
        {
            try
            {
                return "DVT" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new DONVITINH(), null), ConvertClassToArray.GetValues(new DONVITINH(), 1));

            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't Create new DONVITINH"); }
        }
        public bool INSERT(DONVITINH cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Insert new DONVITINH"); }
        }
        public bool UPDATE(DONVITINH cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Update  DONVITINH"); }
        }
        public bool DELETE(DONVITINH cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Delete  DONVITINH"); }
        }
    }
}
